
module BnfHelper  
  require 'libxml'
  def retrieveFile
          result=Bnf.find(:all)           
          xml=LibXML::XML::Document.new()
          xml.root = LibXML::XML::Node.new("collection")                  
          LibXML::XML::Namespace.new(xml.root, nil, 'http://www.loc.gov/MARC21/slim')
            
          result.each {|x| 
            x=x.xml
            old_xml=LibXML::XML::Document.string(x).root
          #converter=MarcTools::MarcConverter.new
          #  marc_hash=converter.marc_to_hash(old_xml)            
          #          marc_hash=converter.changeSubfieldCode(marc_hash,'650$3', '650$a')
          #          marc_hash=converter.moveTag(marc_hash,'240$n', '240$a')
          #          marc_hash=converter.moveTag(marc_hash,'300$c', '300$a')
          #          marc_hash=converter.removeTagbyValue(marc_hash,'700$a', 'unbekannt')
          #          marc_hash=converter.removeTagbyValue(marc_hash,'657$y', 'unbekannt')
          #           new_xml=converter.hash_to_marc(marc_hash)
          a=xml.import(old_xml)
            xml.root << a
          #xml.root << new_xml.root.child
          }
    xml.save('mybnfout.xml', :indent => true, :encoding => LibXML::XML::Encoding::UTF_8)      
        end
end
